package com.hdy.demo.tag.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.hdy.demo.tag.service.PagingService;
import com.hdy.framework.struts2.action.BaseAction;
import com.hdy.framework.tag.paging.IPaging;
import com.hdy.framework.tag.paging.utils.PagingInfoUtils;
import com.hdy.login.dto.UserDto;
//http://127.0.0.1/ssh/tag/helloTagAction.action
@Scope("prototype")
@Component("helloTagAopAction")
public class HelloTagAopAction extends BaseAction implements IPaging{
	private static final long serialVersionUID = -5824911064202817351L;
	private String pagingInfo;

	private List<UserDto> ls;
	private String key;
	private String name;
	@Resource(name="pagingServiceAop")//放在属性可以省略get set方法 也可以放在set方法前面
	private PagingService pagingServiceAop;
	@Override
	public String execute() {
		key = "hello";
		return SUCCESS;
	}
	@Override
	public Map<String,Object> getQueryMap() {
		setParam();
		Map<String,Object> queryMap = new HashMap<String,Object>();
		if(StringUtils.isNotBlank(name)){
			queryMap.put("name", name);
		}
		return queryMap;
	}
	private void setParam(){
		String nameInfo = PagingInfoUtils.get().getString("name", pagingInfo);
		if(StringUtils.isNotBlank(nameInfo)){
			this.name=nameInfo;
		}
		
	}
	@SuppressWarnings("unchecked")
	@Override
	public <T> void setPageList(List<T> ls) {
		this.ls=(List<UserDto>) ls;
	}
	public List<UserDto> getLs() {
		return ls;
	}
	public void setLs(List<UserDto> ls) {
		this.ls = ls;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	public String getPagingInfo() {
		return pagingInfo;
	}
	public void setPagingInfo(String pagingInfo) {
		this.pagingInfo = pagingInfo;
	}
	
}
